export default {
	props: {
		tabIndex: { //当前选中的tab项
			type: Number,
			default: 0
		}
	},
	data() {
		return {
			showTabBar: false,
			showMiddleButton: false,
			tabList: [{
					iconPath: '/static/Index/Index.svg',
					selectedIconPath: "/static/Index/Index_A.svg",
					text: '首页',
					pagePath: '/pages/index/index'
				},

				{
					iconPath: '/static/Index/My.png',
					selectedIconPath: "/static/Index/My_A.svg",
					text: '我的',
					pagePath: '/pages/mine/mine'
				},
			]
		}
	},
	mounted() {
		// this.getSystemInfo()
		// this.setTabBar()
	},
	methods: {
		// setTabBar() {
		// 	let tabLength = this.tabList.length
		// 	if (tabLength % 2) {
		// 		this.showMiddleButton = true
		// 		// 向上取整
		// 		let middleIndex = Math.floor(tabLength / 2)
		// 		// 给中间的添加mid-button
		// 		this.tabList[middleIndex].middleClass = 'mid-button'
		// 	}
		// },

		//点击按钮
		handlePush(item, index) {
			if (this.tabIndex !== index) {

				uni.redirectTo({
					url: item.pagePath
				})
			}
		},

		//兼容iPhoneX以上底部黑线条的显示
		getSystemInfo() {
			//获取系统信息
			uni.getSystemInfo({
				success: (res) => {
					// X及以上的异形屏top为44，非异形屏为20
					if (res.safeArea.top > 20) {
						this.showTabBar = true
					}
				}
			});

		},
	}
}